<template>
	<view class="body">
		<xk-header title="巡查异常处理"></xk-header>
		<view class="list">
			<view class="list-item header" @click="more = !more">
				<view>巡查单号: {{ data.task_no }}</view>
				<image v-if="!more" src="/static/up.png"></image>
				<image v-else src="/static/down.png"></image>
			</view>
			<view v-if="more" class="data-item">
				<view class="order-info">
					<view class="info-item">
						<view class="key">路线名称：</view>{{ data.route_name }}
					</view>
					<view class="info-item">
						<view class="key">巡查事项：</view>{{ data.standard_name }}
					</view>
					<view class="info-item">
						<!-- | formatTime -->
						<view class="key">巡查时段：</view>{{ data.plan_start_time }} - {{ data.plan_end_time  }}
					</view>
				</view>
			</view>
		</view>

		<view v-if="data.status > '20'" class="list">
			<view class="list-item header" @click="orderMore = !orderMore">
				<view>巡查记录</view>
				<image v-if="!orderMore" src="/static/up.png"></image>
				<image v-else src="/static/down.png"></image>
			</view>
			<view v-if="orderMore" class="data-item">
				<view class="order-info">
					<view class="info-item">
						<view class="key">巡查人：</view>{{ data.record_user_name }}
					</view>
					<view class="info-item">
						<view class="key">巡查结果：</view>{{ patrol_result}}
					</view>
					<view @click="viewDetail" class="info-item" style="justify-content: space-between;">
						<view class="key">巡查详情：</view>
						<view style="display: flex; align-items: center;">
							<text class="right-title1" style="color: #2C72FF;">查看明细</text>
							<image mode="aspectFill" class="jiantou" src="/static/jiantou.png" />
						</view>
					</view>
					<view class="info-item">
						<view class="key">完成时间：</view>{{ data.finish_time  }}
					</view>
					<view class="info-item">
						<view class="key">异常描述：</view><text>{{ data.patrol_remark }}</text>
					</view>

					<view v-if="data.deal_user_name" class="info-item">
						<view class="key">处理人：</view><text>{{ data.deal_user_name }}</text>
					</view>
					<view v-if="data.deal_program" class="info-item">
						<view class="key">处理方案：</view><text>{{ data.deal_program }}</text>
					</view>
					<view v-if="data.deal_remark" class="info-item">
						<view class="key">处理备注：</view><text>{{ data.deal_remark }}</text>
					</view>


					<view v-if="data.check_user_name" class="info-item">
						<view class="key">抽查人：</view><text>{{ data.check_user_name }}</text>
					</view>
					<view v-if="data.check_result" class="info-item">
						<view class="key">抽查结果：</view><text>{{ data.check_result == '10' ? '合格' : '不合格' }}</text>
					</view>
					<view v-if="data.check_remark" class="info-item">
						<view class="key">抽查意见：</view><text>{{ data.check_remark }}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="common-bottom-view">
			<view class="common-btn" @click="back">返回</view>
		</view>
		<view class="common-zw"></view>


	</view>
</template>

<script>
import moment from 'moment'
export default {
	data() {
		return {
			taskId: '',
			dets: {},
			data: {},
			more: true,
			orderMore: true,
			patrol_result:'',
		};
	},
	onLoad(options) {
		this.taskId = options.taskId
		this.getData();
	},

	methods: {
		getData() {
			this.$api.baseData_getToolDataList({
				code: "PD_INSPECEL_TASK_PATROL_RESULT" + "_nostr"
			}).then(res => {
				console.log('eeeeeeeeeeeeeeeeeeeeeeeeee', res)
				this.players = res
			})
			this.$api.baseData_getPmPatrolTask(this.taskId).then((res) => {
				this.data = res.task
				if(res.task.patrol_result=='10'){
					this.patrol_result='正常'
				}else{
					this.patrol_result='异常'
				}
				let num = 1;
				for (let index in this.data.dets) {
					let item = this.data.dets[index]
					if (this.dets[item.property_code]) {
						this.dets[item.property_code].data.push(item)
					} else {
						this.dets[item.property_code] = {
							num: num,
							building: item.property_building,
							storey: item.property_storey,
							room: item.property_room,
							data: [item]
						}
						num++;
					}
				}
			})
		},
		viewDetail() {
			uni.navigateTo({
				url: '/pagesA/build-patrol/build-patrol-result-detail?dets=' + JSON.stringify(this.dets)
			})
		},
		back() {
			uni.navigateBack()
		}
	}
}
</script>

<style lang="scss" scoped>
@import '@/common/from.scss';
</style>
